package cn.cjj.gulimall.order.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author CuiJunJie
 * @create 2021/7/8-20:48
 */
@Data
public class OrderConfirmVo {
    private List<MemberAddressVo> address;

    private List<OrderItemVo> items;

    private Integer integration;

    private BigDecimal total;

    private BigDecimal payPrice;

    private String orderToken;

    private Integer count;

    public Integer getCount() {
        Integer sum = 0;
        if (items != null && items.size() > 0) {
            for (OrderItemVo item : items) {
                sum += item.getCount();
            }
        }

        return sum;
    }

    public BigDecimal getTotal() {
        BigDecimal sum = new BigDecimal("0");
        if (items != null && items.size() > 0) {
            for (OrderItemVo item : items) {
                sum = sum.add(item.getTotalPrice());
            }
        }

        return sum;
    }

    public BigDecimal getPayPrice() {
        return getTotal();
    }
}
